{include file="header.tpl"}

   <h1>View Ticket - {$ticket.id}</h1>
   
   <div id="content">
   
      {include file="flashes.tpl"}
      <div class="action_bar">
         <a class="edit" href="?url=tickets/edit/{$ticket.id}">Edit details</a>
         <a class="delete" href="javascript:spf.navigate('tickets', 'delete', '{$ticket.id}', 'Are you sure?')">Delete this ticket</a>
      </div>
      
      <div id="ticket_header" class="panel">
         
         <table rules="none" frame="void">
            <tr>
               <td class="label"><img src="/img/project.png" alt="" />Project:</td>
               <td class="value">{$ticket.project_desc}</td>
               <td class="spacer">&nbsp;</td>
               <td class="label"><img src="/img/type.png" alt="" />Type:</td>
               <td class="value">{$ticket.ticket_type_desc}</td>
            </tr>
            <tr>
               <td class="label"><img src="/img/textfield.png" alt="" />Title:</td>
               <td>{$ticket.title}</td>
               <td class="spacer">&nbsp;</td>
               <td class="label"><img src="/img/component.png" alt="" />Component:</td>
               <td class="value">{$ticket.component_desc}</td>
            </tr>
            <tr>
               <td class="label"><img src="/img/user.png" alt="" />Created:</td>
               <td class="value">{$ticket.created_by}, {$ticket.created_date}</td>
               <td class="spacer">&nbsp;</td>
               <td class="label"><img src="/img/milestone.png" alt="" />Milestone:</td>
               <td class="value">{$ticket.milestone_desc}</td>
            </tr>
            <tr>
               <td class="label"><img src="/img/user.png" alt="" />Updated:</td>
               <td class="value">{$ticket.modifiedcreated_date}</td>
               <td class="spacer">&nbsp;</td>
               <td class="label"><img src="/img/priority.png" alt="" />Priority:</td>
               <td class="value">{$ticket.ticket_priority_desc}</td>
            </tr>
            <tr>
               <td class="label" rowspan="2"><img src="/img/textfield.png" alt="" />Details:</td>
               <td rowspan="2">{$ticket.details|nl2br}</td>
               <td class="spacer">&nbsp;</td>
               <td class="label"><img src="/img/severity.png" alt="" />Severity:</td>
               <td class="value">{$ticket.ticket_severity_desc}</td>
            </tr>
         </table>
         
      </div>
      
      <form id="frm_update_ticket" class="panel" action="" method="post">
         <div class="group">
            <div>
               <label for="ticket_status_id"><img src="/img/status.png" alt="" />Status:</label>
               <select id="ticket_status_id" name="ticket_status_id">
                  <option value="">-- Select A Status --</option>
                  {foreach key=id item=desc from=$ticket_status}
                  <option value="{$id}"{if $id == $ticket.ticket_status_id}{$spf.selected}{/if}>{$desc}</option>
                  {/foreach}
               </select>
               {if $ticket.errors.ticket_status_id}<p class="error">{$ticket.errors.ticket_status_id}</p>{/if}
            </div>
            <div>
               <label for="assigned_user"><img src="/img/user.png" alt="" />Assigned To:</label>
               <select id="assigned_user" name="assigned_user">
                  <option value="">-- Nobody --</option>
                  {foreach key=user_name item=display_name from=$users}
                  <option value="{$user_name}"{if $ticket.assigned_user == $user_name}{$spf.selected}{/if}>{$display_name}</option>
                  {/foreach}
               </select>
               {if $ticket.errors.assigned_user}<p class="error">{$ticket.errors.assigned_user}</p>{/if}
            </div>
         </div>
         <div class="group">
            <div>
               <label for="comment_details"><img src="/img/comment.png" alt="" />Add a comment:</label>
               <textarea id="comment_details" name="comment_details" cols="50" rows="4">{$comment.details}</textarea>
               {if $comment.errors.details}<p class="error">{$comment.errors.details}</p>{/if}
            </div>
         </div>
         
         <div class="button_bar">
            <button type="submit" name="submit_frm_update_ticket" value="1">Submit</button>
         </div>
      </form>
      
      {foreach item=comment from=$comments name=comments}
      <div class="ticket_comment panel">
         {if ($smarty.foreach.comments.index == 0) && ($spf.current_user.user_name == $comment.created_user) }
         <a class="delete" href="javascript:spf.navigate('tickets', 'delete_comment', '{$ticket.id}/{$comment.id}', 'Are you sure?')"><img src="/img/delete.png" alt="Delete" /></a>
         {/if}
         <label><img src="/img/comment.png" alt="" />{$comment.display_name}<span>{$comment.created_date} @ {$comment.created_time}</span></label>
         <p>{$comment.details|nl2br}</p>
      </div>
      {/foreach}
   
      <div class="clear"></div>
   
   </div>

{include file="footer.tpl"}
